#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

int lastStoneWeight(vector<int>& stones) {
    priority_queue<int> heap;

    for (auto& e : stones)
        heap.push(e);

    while (heap.size() > 1)
    {
        int a = heap.top();
        heap.pop();
        int b = heap.top();
        heap.pop();

        if (a != b)
            heap.push(a - b);
    }

    return heap.size() ? heap.top() : 0;
}

int main()
{
	
	return 0;
}